﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using IQKS.AWP.BusinessObject;

namespace IQKS.AWP.DataAccessLayer
{
    public class AssessorCalendarDAL
    {
        public object SetAssessorCalendar(AssessorCalendarBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {
                    new SqlParameter("@CreatedUserID",param.UserID),
                    new SqlParameter("@Remark",param.Remark),
                    new SqlParameter("@StartDate",param.StartDate),
                    new SqlParameter("@EndDate",param.EndDate),
                    new SqlParameter("@AssessorCalendarDetails",param.AssessorCalendarDetails),
                    new SqlParameter("@AssessorCalendar",param.AssessorCalendarID)
			    };
                return DataUtils.ExecuteScalar("USP_SetAssessorCalendar", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }


        public object DeleteAssessorCalendarByID(long lgAssessorCalendarDetailID, int intIsActive )
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {
                    new SqlParameter("@AssessorCalendarDetailID",lgAssessorCalendarDetailID),
                    new SqlParameter("@IsActive",intIsActive)
			    };
                return DataUtils.ExecuteScalar("Usp_SetAssessorCalenderDelete", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }



        public object CheckAssessorAvailabilityByDate(AssessorCalendarBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {
                    new SqlParameter("@CreatedUserID",param.UserID),
                    new SqlParameter("@StartDate",param.StartDate),
                    new SqlParameter("@EndDate",param.EndDate)
			    };
                return DataUtils.ExecuteScalar("USP_CheckAssessorAvailabilityByDate", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public object CheckAssessorAvailabilityUpdate(AssessorCalendarBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {
                    new SqlParameter("@CreatedUserID",param.UserID),
                    new SqlParameter("@AssessorCalendarDetails",param.AssessorCalendarDetails)
			    };
                return DataUtils.ExecuteScalar("USP_CheckAssessorAvailabilityByDateInUpdate", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }

        public DataSet GetAssessorCalendarDetails(AssessorCalendarBO param)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
			    {
                    new SqlParameter("@UserID",param.UserID),
                    new SqlParameter("@AssessorCalendarID",param.AssessorCalendarID),
                    new SqlParameter("@FromDate",param.StartDate),
                    new SqlParameter("@ToDate",param.EndDate)
			    };
                return DataUtils.ExecuteDataset("USP_GetAssessorCalendarDetails", parameters);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }
    }
}
